Skip to content

feat(admin): add date-only content field#1365

Open
masonjames wants to merge 2 commits into
emdash-cms:mainfrom
masonjames:codex/date-only-field-1097
Open

feat(admin): add date-only content field#1365
masonjames wants to merge 2 commits into
emdash-cms:mainfrom
masonjames:codex/date-only-field-1097

Conversation

@masonjames
Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a first-class date-only field type for content models, so authors can collect just a calendar date without forcing a time value.

Discussion: #1097

This PR wires date through the core schema registry, runtime manifest, schema validation, static field helper, MCP schema tools, plugin field-widget manifest validation, and the admin field editor/content editor. Date fields are stored as TEXT in YYYY-MM-DD format and render as <input type="date">; existing datetime behavior is unchanged.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: Date only field #1097

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: GPT-5 Codex

Screenshots / test output

Validated locally:

pnpm lint:json | jq '.diagnostics | length'
pnpm typecheck
pnpm changeset status --since=origin/main
pnpm --filter @emdash-cms/admin exec vitest run tests/components/ContentEditor.test.tsx tests/components/RepeaterField.test.tsx tests/components/FieldEditor.test.tsx
pnpm --filter emdash exec vitest run tests/unit/schema/zod-generator.test.ts tests/unit/schema/registry.test.ts tests/unit/fields/all-fields.test.ts tests/unit/runtime/manifest-build.test.ts tests/unit/plugins/field-widgets.test.ts tests/integration/mcp/schema.test.ts
git diff --check

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 5, 2026

🦋 Changeset detected

Latest commit: 1ceb8c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
emdash Patch
@emdash-cms/admin Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Scope check

This PR touches 24 files. PRs with a broad scope are harder to review. Please confirm the scope hasn't drifted beyond the intended change.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Jun 5, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 5, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1365

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1365

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1365

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1365

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1365

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1365

emdash

npm i https://pkg.pr.new/emdash@1365

create-emdash

npm i https://pkg.pr.new/create-emdash@1365

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1365

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1365

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1365

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1365

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1365

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1365

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1365

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1365

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1365

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1365

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1365

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1365

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1365

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1365

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1365

commit: 1ceb8c8

@masonjames masonjames force-pushed the codex/date-only-field-1097 branch from bb9bdb6 to ecd1d98 Compare June 5, 2026 16:56
Copy link
Copy Markdown
Contributor

@emdashbot emdashbot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a well-scoped, additive feature that mirrors the existing datetime field to provide a date-only option. The implementation is thorough: it threads the new date type through the schema registry, runtime manifest, Zod validation, CLI, MCP tools, plugin manifests, and admin UI (ContentEditor, FieldEditor, RepeaterField). Tests cover the field factory, schema generation, registry column types, runtime manifest, repeater sub-fields, and MCP schema tools. A changeset is present, and all user-facing strings are wrapped for Lingui.

I found two issues:

  1. Timezone bug in toDateOnly (packages/core/src/fields/date.ts). When a Date object is passed to min/max, toISOString().slice(0, 10) can produce the wrong calendar date for timezones east of UTC (e.g. new Date('2026-02-26') in Tokyo becomes "2026-02-25"). This shifts the validation boundary by a day.

  2. Missing regex error message in generated schema (packages/core/src/schema/zod-generator.ts). The runtime-generated Zod schema uses .regex(DATE_ONLY_PATTERN) without a custom message, while the static date() factory provides "Must be a date in YYYY-MM-DD format". API callers get a generic Zod error instead of the helpful message.

No security, SQL injection, auth, or locale-filtering issues were introduced. The approach is sound and the code is otherwise clean.

Comment thread packages/core/src/fields/date.ts
Comment thread packages/core/src/schema/zod-generator.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Jun 5, 2026
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant